﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using CrateMayhem.Common.Controls;
using CrateMayhem.Desktop.Common;

namespace CrateMayhem.Desktop.Controls
{
    public class Crate : Border, ICrate
    {
        private static readonly Brush brush;
        private static readonly Brush targetBrush;
        private static readonly Brush borderBrush;

        public Crate()
        {
            DefaultStyleKey = typeof(Crate);
            CornerRadius = new CornerRadius(2);
            BorderThickness = new Thickness(1);
            Background = brush;
            BorderBrush = borderBrush;
        }

        static Crate()
        {
            brush = Common.Resources.GameStyles.Get<Brush>("CrateBackgroundBrush");
            targetBrush = Common.Resources.GameStyles.Get<Brush>("CrateOnTargetBackgroundBrush");
            borderBrush = Common.Resources.GameStyles.Get<Brush>("BrickBorderBrush");
        }

        public void UpdateBrush(bool onTarget)
        {
            Background = onTarget ? targetBrush : brush;
        }
    }
}